FROM openjdk:8-jre-alpine

ARG SERVICE_NAME=maochd-default-service

ENV SKYWALKING_SERVICE=127.0.0.1:11800

ENV JAR_NAME ${SERVICE_NAME}.jar

ENV SERVICE_NAME ${SERVICE_NAME}

ENV LANG en_US.UTF-8

RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \
    && echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \
    && apk add --no-cache tzdata ttf-dejavu fontconfig \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone

ENV JAVA_OPTS='-Xms512m -Xmx512m -Xss512k'

COPY ${JAR_NAME} /${JAR_NAME}

COPY agent /usr/local/agent

CMD java -javaagent:/usr/local/agent/skywalking-agent.jar \
 -Dskywalking.agent.service_name=$SERVICE_NAME \
 -Dskywalking.collector.backend_service=$SKYWALKING_SERVICE \
  $JAVA_OPTS -jar $JAR_NAME
